package entities

import "mlgmd.com/hearsay/base"

type Reward struct {
	Id           int      `xorm:"pk autoincr" json:"id"`
	CreatorId    int      `json:"creatorId"`
	CreatedTime  int64    `json:"createdTime"`
	DeletedTime  int64    `json:"deletedTime"`
	Content      string   `xorm:"text" json:"content"`
	Images       []string `json:"images"`
	Coin         int      `json:"coin"`
	Weight       int      `json:"weight"`
	WeightBase   int      `json:"weightBase"`
	HearsayCount int      `json:"hearsayCount"`
	CommentCount int      `json:"commentCount"`
	SurplusCoin  int      `json:"surplusCoin"`
	Notice       string   `xorm:"text" json:"notice"` // 管理员:提醒
	Blocked      bool     `json:"blocked"`            // 管理员:已屏蔽
}

func (r *Reward) AfterLoad() {
	if r.Images == nil {
		r.Images = make([]string, 0)
	}
}

type RewardHearsay struct {
	Id          int   `xorm:"pk autoincr" json:"id"`
	RewardId    int   `json:"rewardId"`
	HearsayId   int   `json:"hearsayId"`
	UserId      int   `json:"userId"`
	CreatedTime int64 `json:"createdTime"`
}

type RewardComment struct {
	Comment `xorm:"extends"`
}

func init() {
	base.Must(base.DB.Sync(&Reward{}, &RewardHearsay{}, &RewardComment{}))
}
